package com.kc.gb.device.common.adapter.dto.basic.slot;

import com.kc.gb.device.common.adapter.dto.basic.rack.RackCache;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Comparator;

@Data
public class SlotDto implements Comparable<SlotDto> {
    @ApiModelProperty("主键")
    private Long id;

    // @ApiModelProperty("用途区分")
    // private SlotApplyEnum applyType;

    @ApiModelProperty("warehouseId")
    private Long warehouseId;

    @ApiModelProperty("货位编码")
    private String slotCode;

    private RackCache rack;

    // @ApiModelProperty("货位类型编码")
    // private SlotTypeDto slotTypeDto;

    @ApiModelProperty("库位本身启用状态，不作为业务使用")
    private boolean slotEnable;

    private EnableState enableState;

    @ApiModelProperty("所在货架面")
    private Integer rackHeading;

    @ApiModelProperty("所在货架层")
    private Integer rackLayer;

    /**
     * 库位深度
     * 浅=1
     * 深=2
     */
    @ApiModelProperty("库位深度")
    private Integer slotDepth;

    @ApiModelProperty("库位组编号")
    private String groupSlotCode;

    @ApiModelProperty("槽位简码")
    private String slotName;

    @ApiModelProperty("槽位模式")
    private String slotMode;

    @ApiModelProperty("优先级")
    private Integer priority;

    @ApiModelProperty("槽位单据容量")
    private Integer capacity;
    @ApiModelProperty("槽位商品容量")
    private Integer commodityCapacity;

    @ApiModelProperty("正面PTL编码")
    private Integer frontPTLCode;

    @ApiModelProperty("反面ptl编码")
    private Integer backPTLCode;

    @ApiModelProperty("RFID编码")
    private String rfidCode;

    @ApiModelProperty("距离地面高度")
    private Integer groundHeight;

    @ApiModelProperty("库位位置。仅料箱场景下有意义")
    private SlotPosition slotPosition;

    @ApiModelProperty("整散类型")
    private String dispersionType;

    @ApiModelProperty("库位热度")
    private String slotHot;

    @ApiModelProperty("库位排序")
    private Integer slotNumber;

    @ApiModelProperty("距货架伸叉距离")
    private Integer extensionDistance;

    @ApiModelProperty("容器数字码")
    private Long digitalCode;

    @ApiModelProperty("有横梁码")
    private Boolean barcodeLayer;

    // @ApiModelProperty("状态")
    // private State state;

    private String createUser;

    private String updateUser;

    // private LocalDateTime updateTime;

    // private LocalDateTime createTime;

    @Override
    public int compareTo(SlotDto o) {
        try {
            return Comparator.comparing(SlotDto::getRackHeading)
                    .thenComparing(SlotDto::getRackLayer)
                    .compare(this, o);
        } catch (Exception e) {
            return 1;
        }
    }

    public Long getRackId() {
        return rack == null ? null : rack.getId();
    }

    public String getRackCode() {
        return rack == null ? null : rack.getRackCode();
    }

    public boolean getEnabled() {
        return enableState == EnableState.enable;
    }
}
